<?php

namespace app\common\service;

use app\common\service\Base;
use app\common\model\Banner as BannerModel;

class Banner extends Base {

     public function __construct() {
         parent::__construct();
         $this->currentModel = new BannerModel();
     }

    /**
     * 获取轮播图列表
     * @param $requestMap
     * @return \think\Paginator
     */
    public function getBannerList($requestMap) {

         $list = $this->currentModel
             ->where(getMapFromRequest($requestMap['condition']))
             ->order('id desc')
             ->paginate(Config::get("paginate.list_rows"),false,
                 ["query"=>$requestMap['page']]);

         return $list;
    }

    /**
     * 获取有效banner
     * @return array|\PDOStatement|string|\think\Collection
     */
    public function getValidList() {

        $map['status'] = config("enum.bannerStatus.valid.value");

        $list = $this->currentModel
            ->where($map)
            ->select();

        return $list;

    }

}